package com.fenqing.leetcode.code.t600_700;

import com.fenqing.annotations.Execute;
import com.fenqing.core.Topic;

/**
 * @author fenqing
 */
public class Topic771 extends Topic {

    /**
     * 构造器
     * @param input1 输入1
     * @param input2 输入2
     */
    public Topic771(String input1, String input2) {
        super(input1, input2);
    }

    @Execute
    public int numJewelsInStones(String jewels, String stones) {
        boolean[] chars = new boolean[26 << 1];
        char[] cs = jewels.toCharArray();
        for (char c : cs) {
            chars[index(c)] = true;
        }
        int count = 0;
        char[] chars1 = stones.toCharArray();
        for (char c : chars1) {
            if (chars[index(c)]) {
                count++;
            }
        }
        return count;
    }

    public int index(char ch){
        if (ch >= 'A' && ch <= 'Z'){
            return 26 + ch - 'A';
        } else {
            return ch - 'a';
        }
    }

    public static void main(String[] args) {
        Topic771 topic771 = new Topic771("z", "ZZ");
        Integer run = topic771.run();
        System.out.println(run);
    }

}
